<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<c:set var="path" value="${pageContext.request.contextPath }" />
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<LINK rel="Bookmark" href="../images/favicon.ico">
<!-- 本框架基本脚本和样式 -->
<script type="text/javascript"
	src="${path }/resource/js/jquery-2.1.4.min.js"></script>
<script type="text/javascript"
	src="${path }/resource/js/systools/MBase.js"></script>
</head>
<body>
	<div class="ibox-content">
		<form class="form-horizontal " id="dataform"
			onsubmit="javascripr:return false;">
			<c:if test="${obj ne null }">
				<input type="hidden" name="id" value="${obj.id }">
			</c:if>
			<div class="form-group">
				<label class="col-offset-1 col-sm-2 control-label">父级功能</label>
				<div class="col-sm-3">
					<select class="form-control  select2" size="1" name="parentId"
						id="parentId">
						<option value="-10" selected="selected">一级功能</option>
					</select>
				</div>

				<label class="col-sm-2 control-label">功能名称</label>
				<div class="col-sm-3">
					<input name="name" type="text" class="form-control " nullmsg="功能名称不能为空"
						datatype="*1-50">
					<div class="Validform_checktip"></div>
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-2 control-label">访问路径</label>
				<div class="col-sm-3">
					<input name="functionPath" type="text" class="form-control" >
				</div>
				<label class="col-sm-2 control-label">功能图标</label>
				<div class="col-sm-3">
					<input name="icon" type="text" id="iconText" class="form-control"  onclick="showIcon()">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">排序</label>
				<div class="col-sm-3">
					<input name="sortIndex" type="number" class="form-control" >
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">功能按钮</label>
				<div class="col-sm-9" id="btns">
					<c:forEach items="${btnList }" var="item">
						<div class="checkbox checkbox-inline">  <input  name="btns" type="checkbox" id="inlineCheckbox${item.btnValue }" value="${item.btnValue }">   		
						<label for="inlineCheckbox${item.btnValue }"> ${item.btnKey } </label> </div>
					</c:forEach>
				</div>
			</div>

			<div class="form-group ">
				<div class="col-12 text-center">
					<a href="javascript:;" onclick="myForm.submit()"
						class="btn btn-success radius">保存</a>&nbsp;&nbsp;&nbsp;&nbsp; <input
						type="reset" class="btn btn-danger radius" value="重置" />
				</div>
			</div>
		</form>
	</div>
	<script type="text/javascript">
	$(".select2").select2();
	var myForm=null;	
	$(function() {
		myForm=MForm.initForm({
				invokeUrl:"${path}/developer/function/addOrModify",
				afterSubmit : function() {
					parent.initFunctionList();
				}
			});
			initFunctionList();
		});

		/**
		 * 初始化功能列表
		 */
		function initFunctionList() {
			$.AjaxProxy({
				a : false,
				c : false
			}).invoke("${path}/developer/function/all", function(loj) {
				$("#parentId").createSelectTree(loj.attr("result").rows, {
					append : true
				});
			});

		}

		function showIcon() {
			layer.open({
				type : 2,
				title : "选择图标",
				area : [ '80%', '80%' ],
				fix : true, // 不固定
				maxmin : true,
				content : '${path}/common/redirect/icons'
			});
		}
	</script>
</body>
</html>